from api_1_0.view import blue
from ..models import EducationCount,EducationSalary,ExperienceCount,ExperienceSalary,WelfareCount,CityJobs
from flask import render_template
@blue.route('/drawLine')
def drawLine():
    exp_data = ExperienceSalary.query.all()
    exp_date = [i.exp_date for i in exp_data]
    exp_sal = [i.salary for i in exp_data]
    edu_data = EducationSalary.query.all()
    edu_level = [i.edu_level for i in edu_data]
    edu_sal = [i.salary for i in edu_data]
    return render_template('showLine.html',**locals())

@blue.route('/drawGeo')
def drawGeo():
    city_jobs_data = CityJobs.query.all()
    city_job = [{'name':i.city,'value':i.count} for i in city_jobs_data]
    return render_template('showGeo.html',**locals())

@blue.route('/drawBar')
def drawBar():
    exp_count_data = ExperienceCount.query.all()
    exp_date = [i.exp_date for i in exp_count_data]
    count = [i.count for i in exp_count_data]
    return render_template('showBar.html',**locals())

@blue.route('/drawPie')
def drawPie():
    wel_count_data = WelfareCount.query.all()
    wel_count = [{'name':i.welfare,'value':i.count} for i in wel_count_data]
    edu_count_date = EducationCount.query.all()
    edu_count = [{'name':i.edu_level,'value':i.count} for i in edu_count_date]
    return render_template('showPie.html', **locals())

